package com.qk.common.util;

public class CurrentUserContextHolders {
    private CurrentUserContextHolders(){}

    // 创建一个ThreadLocal对象 用来保存当前用户信息
    // 隐藏一个设计模式单例设计模式 饿汉式
    private static final ThreadLocal<Integer> currentUser = new ThreadLocal<>();

    public static void set(Integer id){
        currentUser.set(id);
    }

    public static Integer get(){
        return currentUser.get();
    }

    public static void remove(){
        currentUser.remove();
    }
}
